//
//  SearchViewController.m
//  SalonManage
//
//  Created by tim on 2017/7/28.
//  Copyright © 2017年 lmtt. All rights reserved.
//

#import "SearchViewController.h"
#import "OrderDetailViewController.h"

#import "OrderCell.h"

@interface SearchViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UIView *contentView;

@property (nonatomic,strong) UIView * searchView;
@property (nonatomic,strong) LMCellView * dataView;
@property (nonatomic,strong) LMCellView * orderView;
@property (nonatomic,strong) LMButton * searchBtn;

@property (nonatomic,strong) UITableView * mainTableView;
@end

@implementation SearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitle:@"查询订单"];
    
    [self initWithSubViews];
}

-(void)initWithSubViews{
    self. contentView.frame = CGRectMake(0, 64, __kScreenWidth, __kScreenHeight - 64);
    self.contentView.backgroundColor = HGCOLOR(@"ffffff");
    [self.view addSubview:self.contentView];
    
    //搜索视图
    [self.contentView addSubview:self.searchView];
    [self.searchView addSubview:self.dataView];
    [self.searchView addSubview:self.orderView];
    [self.searchView addSubview:self.searchBtn];
    
    self.searchView.frame = CGRectMake(0, 0, __kScreenWidth, HGADPT(220));
    
    self.dataView.frame = CGRectMake(HGADPT(0), HGADPT(20), __kScreenWidth/2, HGADPT(80));
    self.orderView.frame =  CGRectMake(HGADPT(0), self.dataView.bottom+HGADPT(20), self.dataView.width, self.dataView.height);
    self.searchBtn.frame = CGRectMake(0, 0, 90, 30);
    self.searchBtn.centerY = self.searchView.centerY;
    self.searchBtn.right = __kScreenWidth-HGADPT(30);
    
    self.navigationController.navigationBar.translucent = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self. mainTableView= [[UITableView alloc] initWithFrame:CGRectMake(0, self.searchView.bottom, __kScreenWidth, __kScreenHeight-64-49) style:UITableViewStylePlain];
    
    self. mainTableView.delegate = self;
    self. mainTableView.dataSource = self;
    self. mainTableView.separatorColor = [UIColor clearColor];
    self. mainTableView.showsVerticalScrollIndicator=NO;
    self. mainTableView.showsHorizontalScrollIndicator=NO;
    
    [self.contentView addSubview:self. mainTableView];
 
}


#pragma mark - UITableViewDataSource
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{

    return 10;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)sectio
{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 180;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
{
    
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 1;
    
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *CellIdentifier = @"OrderCell";
    OrderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell) {
        NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"OrderCell" owner:nil options:nil];
        cell = [nibs lastObject];
    }
    cell.selected = NO;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.backgroundColor = [UIColor whiteColor];
    cell.readBlock = ^{
        
        NSLog(@"indexPath%ld",indexPath.section);
        OrderDetailViewController * detailVC = [[OrderDetailViewController alloc]init];
        [self.navigationController pushViewController:detailVC animated:YES];
    };
    
    return cell;
}



#pragma mark -懒加载

-(UIView *)contentView{
    if (_contentView == nil) {
        _contentView = [[UIView alloc]init];
    }
    return _contentView;
}

-(UIView *)searchView{
    if (_searchView == nil) {
        _searchView = [[UIView alloc]init];
        
    }
    return _searchView;
}
-(LMCellView *)dataView{
    if (_dataView == nil) {

        
        _dataView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{

        }];
        _dataView.textLabel.text = @"工号";
        _dataView.detailFied.placeholder = @"请输入工号";
        _dataView.detailLeft = HGADPT(120);
        [_dataView removeLine];
    }
    return _dataView;
}

-(LMCellView *)orderView{
    if (_orderView == nil) {
        _orderView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _orderView.textLabel.text = @"单号";
        _orderView.detailFied.placeholder = @"请输入单号";
        _orderView.detailLeft = HGADPT(120);
        [_orderView removeLine];
    }
    return _orderView;
}

-(LMButton *)searchBtn{
    if (_searchBtn == nil) {
        _searchBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"查找"];
        
        _searchBtn.onClick = ^(LMButton *btn) {
            
            
        };
    }
    return _searchBtn;
}

@end
